

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/installement")
public class installement extends HttpServlet {
	private static final long serialVersionUID = 1L;
      public installement() throws ClassNotFoundException {
        super();
        Class.forName ("org.sqlite.JDBC");

    }
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		try {
			Connection conn = DriverManager.getConnection("jdbc:sqlite:cms.db");
			String name="bcsf11a001";
			String s=null;
			PreparedStatement preStatement = conn.prepareStatement("select req from fee where roll= ?");
			PreparedStatement preStatement1=null;
		    preStatement.setString(1, name);
		    ResultSet res=preStatement.executeQuery();
		    if(res.getString(1).equals("0"))
		    {
		    	preStatement1 = conn.prepareStatement("update fee set req=\'1\' where roll= ?");
		    	preStatement1.setString(1, name);
		    	preStatement1.executeUpdate();
		    	preStatement1.close();
		    	s="request submitted for fee installement";
		    }
		    else
		    {
		    	s="request alreadyp'["
		    			+ "] submitted";
		    }
		    response.getWriter().println(s);
		    preStatement.close();
			conn.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}



	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	}

}
